var APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
var RESPONSE_OK = 20000;
/**
 * 接口密钥
 */
const appChannel = "APP";
const appId = "440041";
const appSecret = "464340fda97bbdab3463e676977c165d";

/** 接口主机地址 */
// var host = "http://testapi.tiexiemall.com";
//    var host = "https://api.tiexiemall.com";
var host = "http://api.tiexiecloud.com:81";

// var host = "http://192.168.1.182:9101";
// var host = "http://192.168.1.93:9101";
// var host = "http://192.168.1.72:9101";
// var host = "http://api.tiexie.jiedu.mobi";


// 完整的请求如下git
// IP地址：端口：服务地址：权限：xxx
// IP:PROT:API_SERVICE:API_PERMISSION:XXX

// 服务地址
const API_SERVICE = {
    CONTENT: "/content",
    USER: "/user",
    PRODUCT: "/product",
    ORDER: "/order"
};
// 此处的数据请参照接口文档的描述部分
const API_PERMISSION = {
    // PUBLIC值为[pl],代表[公用],
    PUBLIC: "/pl",
    // 值为[ul],代表[需要登陆]
    USER: "/ul",
    // AUTH_USER值为[ua],代表[需要登陆的用户已经认证],
    AUTH_USER: "/ua",
    // ADMIN值为[al],代表[管理员]
    ADMIN: "/al"
};

var interfaces = {
    // 用户接口 service-user接口
    USER_MODULE: {
        // 提交意见反馈
        ADD_FEEDBACK: API_SERVICE.USER + API_PERMISSION.USER + "/feedback",
        // 获取用户信息
        GET_USER_INFO: API_SERVICE.USER + API_PERMISSION.USER + "/user/base_info/get_user_info",
        // 获取用户基本信息
        GET_USER_BASE_INFO: API_SERVICE.USER + API_PERMISSION.USER + "/user/base_info/get_user_base_info",
        // 更新用户信息
        UPDATE_USER_INFO: API_SERVICE.USER + API_PERMISSION.USER + "/user/base_info/update_user_info",
        // 修改用户手机信息
        UPDATE_USER_PHONE: API_SERVICE.USER + API_PERMISSION.USER + "/user/base_info/update_user_phone",
        //获取我的邀请码
        GET_USER_CODE: API_SERVICE.USER + API_PERMISSION.USER + "/user/my_promo_code",
        //获取邀请列表
        GET_USER_INVITE_LIST: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/user/my_invite",
        // 获取用户钱包汇总
        GET_USER_WALLET_INFO: API_SERVICE.USER + API_PERMISSION.USER + "/user/wallet_log/total",
        // 钱包明细
        GET_USER_WALLET_LOG: API_SERVICE.USER + API_PERMISSION.USER + "/user/wallet_log",
        // 提现
        WALLET_WITHDRAWAL: API_SERVICE.USER + API_PERMISSION.AUTH_USER + "/user/wallet_log",
        //邀请数据统计
        INVITE_TAOTAL_DATA: API_SERVICE.USER + API_PERMISSION.USER + "/user/user_invite/total",
        //查看有多少人拿到佣金
        INVITE_TAOTAL_COUNT: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/user/brokers/count",
        // 提交问卷调查
        SUBMIT_QUESTIONNAIRE: API_SERVICE.USER + API_PERMISSION.USER + "/user/question",

        USER: {
            // 绑定手机号
            BIND_PHONE: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/user/bind_phone",
            BIND_QQ: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/bind/qq/l",
        },
        MESSAGE: {
            //    获取消息列表
            // /ul/messages
            GET_MESSAGELIST: API_SERVICE.USER + API_PERMISSION.USER + "/messages",
            // 阅读消息
            // /ul/messages/{id}/read
            READ_MESSAGE: API_SERVICE.USER + API_PERMISSION.USER + "/messages/",

            GET_UN_READ_NUM: API_SERVICE.USER + API_PERMISSION.USER + "/messages/num"
        },
        AUTHORIZATION: {
            // 上传身份证照片路径
            UPLOAD_IDCARDPHOTO: API_SERVICE.USER + API_PERMISSION.USER + "/certification/upload",
            // 商铺认证-个人认证
            MY_AUTHORIZATION: API_SERVICE.USER + API_PERMISSION.USER + "/certification/personal",
            // 商铺认证-商家认证
            MERCHANT_AUTHORIZATION: API_SERVICE.USER + API_PERMISSION.USER + "/certification/merchant",
            // 认证状态
            AUTHORIZATION_STATUS: API_SERVICE.USER + API_PERMISSION.USER + "/certification/status",
            // 认证详情
            AUTHORIZATION_DETAIL: API_SERVICE.USER + API_PERMISSION.USER + "/certification/detail",
        },
        SHOP: {
            // 获取用户店铺信息
            // /ua/user/base_info/get_user_shop
            GET_USERSHOPINFO: API_SERVICE.USER + API_PERMISSION.AUTH_USER + "/user/base_info/get_user_shop",
            // 修改用户店铺信息
            // /ua/user/base_info/update_user_shop
            UPDATE_USERSHOPINFO: API_SERVICE.USER + API_PERMISSION.AUTH_USER + "/user/base_info/update_user_shop",
            // 获取店铺客服链接
            KF_URL: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/kf/info",
        },
        CART: {
            // 获取购物车列表
            // /pl/carts
            GET_CARTLIST: API_SERVICE.USER + API_PERMISSION.USER + "/carts",
            // 修改购物车数量
            // /pl/carts put
            PUT_CARTLIST: API_SERVICE.USER + API_PERMISSION.USER + "/carts",
            // 加入购物车
            // /ul/carts
            ADD_CART: API_SERVICE.USER + API_PERMISSION.USER + "/carts",
            // 批量删除购物车商品
            DEL_CART: API_SERVICE.USER + API_PERMISSION.USER + "/carts/batch",
            // 构建订单
            // /ul/user_orders/build
            POST_ORDER: API_SERVICE.USER + API_PERMISSION.USER + "/user_orders/build"
        },
        ADDR: {
            // 收货地址分页列表
            // /ul/receivers
            GET_ADDRLIST: API_SERVICE.USER + API_PERMISSION.USER + "/receivers",
            // 设置为默认收货地址
            // /ul/receivers/set_default/{id}
            SET_DEFAULTADDR: API_SERVICE.USER + API_PERMISSION.USER + "/receivers/set_default",
            // 用户添加一个用户地址
            // /ul/receivers
            ADD_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/receivers",
            // 用户编辑一个用户地址
            // /ul/receivers
            EDIT_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/receivers",
            // 移除一个收货地址
            // /ul/receivers/{id}
            DELETE_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/receivers"
        },
        ADDRESS: {
            // 收货地址分页列表
            // /ul/receivers
            GET_ADDRLIST: API_SERVICE.USER + API_PERMISSION.USER + "/user_address",
            // 设置为默认收货地址
            // /ul/receivers/set_default/{id}
            SET_DEFAULTADDR: API_SERVICE.USER + API_PERMISSION.USER + "/user_address/set_default",
            // 用户添加一个用户地址
            // /ul/receivers
            ADD_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/user_address",
            // 用户编辑一个用户地址
            // /ul/receivers
            EDIT_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/user_address",
            // 移除一个收货地址
            // /ul/receivers/{id}
            DELETE_ADDR: API_SERVICE.USER + API_PERMISSION.USER + "/user_address"
        },
        /**
         * 收藏相关
         */
        COLLECTION: {
            // 获取分页收藏列表
            GET_PAGE: API_SERVICE.USER + API_PERMISSION.USER + '/collection/page',
            // 删除收藏
            DEL_COLLECT: API_SERVICE.USER + API_PERMISSION.USER + '/collection/remove',
            // 获取分页浏览列表
            GET_COLLECT: API_SERVICE.USER + API_PERMISSION.USER + '/browse/page',
            // 添加用户收藏
            ADD_COLLECT: API_SERVICE.USER + API_PERMISSION.USER + '/collection/add',
            // 用户取消收藏
            CANCEL_COLLECT: API_SERVICE.USER + API_PERMISSION.USER + '/collection/cancel',
            // 检查是否收藏，传入对应列表的ID，返回收藏的ID
            CHECK_HAS_COLLECT: API_SERVICE.USER + API_PERMISSION.USER + '/browse/check_has_collection'
        },
        /**
         * 浏览相关
         */
        BROWSE: {
            // 添加用户浏览
            ADD_BROWSE: API_SERVICE.USER + API_PERMISSION.USER + '/browse/add',
            // 获取分页浏览列表
            GET_BROWSE: API_SERVICE.USER + API_PERMISSION.USER + '/browse/page',
            // 删除浏览记录
            DEL_BROWSE: API_SERVICE.USER + API_PERMISSION.USER + '/browse/remove'
        },
        /**
         * 用户id获取店铺信息
         */
        STORE: {
            GET_STORE_INFO: API_SERVICE.USER + API_PERMISSION.PUBLIC + '/user/shop_info',
        },
        LOGIN: {
            // 验证码登陆
            CODE_LOGIN: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/auth/login",
            // 三方登陆
            THIRD_LOGIN: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/auth/third",
            // 退出登陆
            LOGOUT: API_SERVICE.USER + API_PERMISSION.USER + "/auth/logout",
            // 扫描二维码，进行用户绑定二维码值-app
            SCAN_QR_CODE: API_SERVICE.USER + API_PERMISSION.USER + "/scan_auth/scan/scan_qr_code",
            // 确认登陆-app
            SCAN_CONFIRM_LOGIN: API_SERVICE.USER + API_PERMISSION.USER + "/scan_auth/scan/confirm_login",
            ONE_KEY_LOGIN: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/auth/one_key_login"
        }
    },
    // 内容模块
    CONTENT_MODULE: {
        // 上传图片
        UPLOAD_IMAGE: API_SERVICE.CONTENT + API_PERMISSION.USER + "/upload/image",
        UPLOAD_VIDEO: API_SERVICE.CONTENT + API_PERMISSION.USER + "/upload/video",
        UPLOAD_IMAGE_PART: API_SERVICE.CONTENT + API_PERMISSION.USER + "/upload/image_part",
        // 获取定位城市列表
        GET_LOCATION: API_SERVICE.CONTENT + API_PERMISSION.USER + "/areas/location_cities",


        HOME: {
            //首页头条
            GET_HEADLINE_LIST: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/headline",
            //首页推荐
            GET_RECOMMEND_VIDEO: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moments/recommended",
        },
        // 视频点播
        VOD: {
            // 获取播放地址
            GET_VIDEO_PLAY: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/vod/video/get_play",
            // 获取视频信息
            GET_VIDEO_INFO: API_SERVICE.CONTENT + API_PERMISSION.USER + "/vod/video/get_info",
            // 获取视频鉴权
            GET_VIDEO_AUTH: API_SERVICE.CONTENT + API_PERMISSION.USER + '/upload/video/get_auth',
            // 刷新视频鉴权
            REFRESH_VIDEO_AUTH: API_SERVICE.CONTENT + API_PERMISSION.USER + '/upload/video/refresh',
        },

        INFO: {
            // 添加一个常见问题
            // /pl/question/add
            ADD_QUESTION: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/question/add",
            // 常见问题列表
            // /pl/question/list
            GET_QUESTIONLIST: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/question/list",
            // 获取静态资源列表
            // /pl/static_contents
            GET_STATICLIST: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/static_contents"

        },
        AREA: {
            //  获取城市列表 （关键字获取）
            GET_CITYLIST: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/areas/location_cities",
            GET_PROVINCE: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/areas/province",
            // 根据关键字搜索城市 用于发布 所在地
            GET_SEARCH_PLACE: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/areas/search_place"
        },
        CIRCLE: {
            // 记录动态点击量
            RECORD_VIEW_NUM: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moment/addTopicHitNum",
            // 记录动态转发量
            RECORD_SHARE_NUM: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moment/forwardTopic",
            // 获取所有动态
            GET_ALL_NEWSFEED: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moments/all",
            // 点赞用户动态
            LIKES_NEWS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moment/popular",
            // 取消点赞用户动态
            UNLIKES_NEWS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moment/unpopular",
            // 点赞评论
            LIKES_COMMENT: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/comment/thumbsMoment",
            // 取消点赞评论
            UNLIKES_COMMENT: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/comment/unThumbsMoment",
            // 关注用户
            // /pl/attention/user/{userId}
            CONCERN_USER: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/attention/user",
            // /pl/attention/un/user/{userId}
            // 取消关注用户
            UNCONCERN_USER: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/attention/un/user",
            // 获取我的关注
            // /pl/moments/all/follow
            GET_MYCONCERN: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/all/follow",

            // 获取评论详情
            GET_MOMENTS: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moments/getMomentComments",
            // 获取动态详情
            GET_NEWDETAIL: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moment/detail",
            GET_VIDEO_DETAIL: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moments/getTopicBeforeAndAfter",
            // 滑动加载更多视频列表
            GET_MORE_NEWDETAIL: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/new/moments/slideVideo",
            // 评论某个动态
            // /ul/comment/moment
            COMMENTON_NEWS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/comment/moment",
            // 发布动态
            // /pl/moments/publish post
            PUBLISH_NEWS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/publish",
            // 获取我的所有动态
            LIST_ALL_MIME_MOMENTS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/all/mime",
            // 获取我关注的视频列表
            LIST_ALL_MIME_FOCUS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/listTopicsFollow",
            // 获取我点赞的视频列表
            LIST_ALL_MIME_LIKE: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/listTopicsEnjoy",

            // 删除一条动态
            DELETE_MOMENTS: API_SERVICE.CONTENT + API_PERMISSION.USER + "/new/moments/remove/",

            //新增视频统计
            ADD_VIDEO_DUTATION: API_SERVICE.USER + API_PERMISSION.USER + "/topicNewReport/create",
        },
        SYSTEM: {
            GET_SYSTEM: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/settings/config"
        },
        SMS: {
            // 发送验证码
            SEND_CODE: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/sms/send_code",
            // 校验验证码
            CHECK_CODE: API_SERVICE.CONTENT + API_PERMISSION.PUBLIC + "/sms/check_code",
        }
    },
    // 产品模块
    PRODUCT_MODULE: {
        // 获取标签
        LIST_TAGS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/tags",
        // 获取品类，类型，型号
        LIST_CATEGORIES: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/categories",
        // 获取品牌
        LIST_BRANDS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/brands",
        // 根据类型获取选项列表
        LIST_OPTIONS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/options",

        // 发布求购求租设备
        PUBLISH_EQUIPMENT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/equipments",
        // 发布用工招聘
        PUBLISH_RECRUIT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/recruits",
        // 优惠券列表
        GET_LIST_PROMOTIONS: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + '/promotions',

        GET_LIST_PRODUCT_PROMOTIONS: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + '/promotions/product',

        // 发布维修保养
        PUBLISH_MAINTENANCE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/maintenance",
        // 发布视频展示
        PUBLISH_VIDEO_SHOW: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/video_shows",
        // 更新视频
        UPDATE_VIDEO_SHOW: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/video_shows",
        // 上下架
        UPDATE_STATUS_VIDEO_SHOW: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/video_shows/status",
        // 举报
        // /ul/complaints
        REPORT_CONTENT: API_SERVICE.PRODUCT + API_PERMISSION.USER + "/complaints",
        STORAGE: {
            // 发布仓储
            PUBLISH_STORAGE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/storage",
            // 仓储详情
            STORAGE_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/storage/",
            // 更新
            UPDATE_STORAGE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/storage",
            // 更新上下架
            UPDATE_STATUS_STORAGE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/storage/status/",
        },

        LOGISTIC: {
            // 发布物流(货找车、车找货)
            PUBLISH_LOGISTIC: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/logistics",
            // 更新
            UPDATE_LOGISTIC: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/logistics",
            // 更新上下架
            UPDATE_STATUS_LOGISTIC: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/logistics/status/",
        },

        // 首页
        INDEX: {
            // 获取首页轮播和视频秀数据
            // /pl/index/app get
            GET_INDEXDATA: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/index/newApps",
            // 获取视频展示列表
            VIDEO_SHOWS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/video_shows",
            // 获取详情
            VIDEO_SHOWS_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/video_shows/",

        },
        // 菜单
        MENUICON: {
            RONGZIBAOXIAN: {
                // 获取融资保险列表
                // /pl/insurances
                // 获取融资保险详情
                // /pl/insurances/{id}
                GET_INSURANCE: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/insurances",

            },
            EMPLOYMENT: {
                // 获取用工招聘列表
                // /pl/recruits
                GET_EMPLOYMENT: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/recruits",
                // 获取用工招聘详情
                // /pl/recruits/{id}
                GET_EMPLOYMENT_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/recruits/",
                // 更新招聘
                UPDATE_EMPLOYMENT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/recruits",
                // 更新上下架
                UPDATE_STATUS_EMPLOYMENT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/recruits/status/",
            },
            LOGISTICS: {
                // 获取物流列表
                // /pl/logistics
                GET_LOGISTICSLIST: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/logistics",
                // 获取仓储列表
                // /pl/storage
                GET_STOREHOUSELIST: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/storage"

            }

        },
        SEARCH: {
            // 搜索各模块数量
            // /pl/index/search_module_count
            SEARCH_MODULECOUNT: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/index/search_module_count"
        },
        // 维修相关
        MAINTENANCE: {
            // 获取维修保养列表
            GET_MAINTENANCE: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/maintenance",
            // 获取维修保养详情
            GET_DETAIL_MAINTENANCE: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/maintenance/",
            // 获取我的维修保养详情
            MINE_MAINTENANCE_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/maintenance/mine",
            // 上下架
            UPDATE_STATUS_MAINTENANCE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/maintenance/status",
            // 更新
            UPDATE_MAINTENANCE: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/maintenance"
        },
        // 商品 0设备售卖 1设备出租 2配件
        PRODUCT: {
            // 获取商品列表 0设备售卖 1设备出租 2配件
            GET_PRODUCTS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/products",
            // 发布设备出售、出租、配件
            PUBLISH_PRODUCT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/products",
            // 获取商品详情
            GET_PRODUCT_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/products/",
            // 更新商品
            UPDATE_PRODUCT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/products",
            // 更新上下架
            UPDATE_STATUS_PRODUCT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/products/status/",
        },
        // 设备
        EQUIPMENT: {
            // 获取设备列表
            GET_EQUIPMENTS: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/equipments",
            // 获取设备详情
            GET_EQUIPMENT_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/equipments/",
            // 更新设备
            UPDATE_EQUIPMENT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/equipments",
            // 更新上下架
            UPDATE_STATUS_EQUIPMENT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/equipments/status/",
        },
        //异型钢
        DEFORMED: {
            // 获取异型钢分类列表
            GET_DEFORMED_CATEGORY: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/class",
            // 获取异型钢列表
            GET_DEFORMED_LIST: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/steels",
            // 获取异型钢详情
            GET_DEFORMED_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/steels/",
            // 发布异型钢
            PUBLISH_DEFORMED: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/steels",
            // 更新上下架
            UPDATE_STATUS_DEFORMED: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/steels/status/",
            // 更新异型钢
            UPDATE_DEFORMEDT: API_SERVICE.PRODUCT + API_PERMISSION.AUTH_USER + "/steels",

        },
        //新闻资讯
        NEWS: {
            // 获取资讯列表
            GET_NEWS_LIST: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/information/queryPage",
            // 获取新闻频道
            GET_NEWS_CHANNLE: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/options/findByTypeAndStatus",
            // 资讯详情
            GET_NEWS_DETAIL: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/information/getDataById",
            // 添加浏览记录
            ADD_NEWS_LOOK: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/information/addLookNum",
    },
    BANNER: {
        GET_BANNER: API_SERVICE.PRODUCT + API_PERMISSION.PUBLIC + "/index/banners",
    },
    /**
     * 收藏相关
     */
    COLLECTION: {
        // 获取分页收藏列表
        GET_PAGE: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/collection/page',
        // 删除收藏
        DEL_COLLECT: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/collection/remove',
        // 获取分页浏览列表
        GET_COLLECT: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/browse/page',
        // 添加用户收藏
        ADD_COLLECT: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/collection/add',
        // 用户取消收藏
        CANCEL_COLLECT: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/collection/cancel',
        // 检查是否收藏，传入对应列表的ID，返回收藏的ID
        CHECK_HAS_COLLECT: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/browse/check_has_collection'
    },
    /**
     * 浏览相关
     */
    BROWSE: {
        // 添加用户浏览
        ADD_BROWSE: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/browse/add',
        // 获取分页浏览列表
        GET_BROWSE: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/browse/page',
        // 删除浏览记录
        DEL_BROWSE: API_SERVICE.PRODUCT + API_PERMISSION.USER + '/browse/remove'
    },
},
    ORDER_MODULE: {
        ORDER: {
            // 获取店铺出售订单列表
            // /ua/shop_orders
            GET_SELL: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/shop_orders/v2",
                GET_SHOP_ORDERS: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/shop_orders",
                    // 获取用户的订单列表
                    // /ul/user_orders
                    // 获取用户的订单详情
                    // /ul/user_orders/{id}
                    GET_USER_ORDERS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders",
                        // 构建用户订单
                        // /ul/user_orders/build
                        BUILD_USER_ORDERS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/build",
                            // 创建用户订单
                            // /ul/user_orders/create
                            CREATE_USER_ORDERS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/create",
                                // 检查支付单状态
                                // /pay/status/{sn}
                                CHECK_STATUS: API_SERVICE.ORDER + API_PERMISSION.USER + "/pay/status/",
                                    // 订单支付
                                    // /ul/user_orders/pay
                                    PAY_ORDERS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/pay",
                                        SEE_LOGISTICS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/",
                                            USER_ORDER: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/",
                                                RETURN_LOGISTICS: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/return_logistics",
                                                    GET_EXPRESS: API_SERVICE.ORDER + API_PERMISSION.PUBLIC + '/express_companies',
                                                        // 优惠券列表
                                                        GET_DISCOUNTS_LIST: API_SERVICE.ORDER + API_PERMISSION.USER + "/coupons"
        },
WITHDRAW: {
    // 店铺金额
    // /ua/withdraw/shop_balance
    GET_WITHDRAWMONEY: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/shop_balance",
        // 获取历史提现记录
        // /ua/withdraw/history
        GET_WITHDRAWHISTORY: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/history",
            // 获取提现中的记录
            // /ua/withdraw/wait
            GET_WITHDRAWING: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/wait",
                // 管理员审核提现通过
                // /ua/withdraw/approve
                PERMIT_WITHDRAW: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/approve",
                    // 申请提现
                    // /ua/withdraw/apply
                    APPLY_WITHDRAW: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/apply",
                        // 获取未提现的订单
                        // /ul/user_orders/withdraw
                        GET_UNDRAW: API_SERVICE.ORDER + API_PERMISSION.USER + "/user_orders/withdraw",
                            // 申请提现
                            // /ua/withdraw/apply
                            REQUEST_WITHDRAW: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw/apply",

                                // 陆
                                // 获取金额记录
                                // /ua/withdraw
                                GET_BALANCE: API_SERVICE.ORDER + API_PERMISSION.AUTH_USER + "/withdraw"

}
    },

GET_VIDEO_AUTH: API_SERVICE.CONTENT + API_PERMISSION.USER + '/upload/video/get_auth', //获取视频鉴权

    GT_AUTH: API_SERVICE.USER + API_PERMISSION.PUBLIC + '/geetest/first', //get 获取激验一次  post 二次
        // 腾讯防水墙验证
        TWF: API_SERVICE.USER + API_PERMISSION.PUBLIC + '/twf/verify',
            // GT_AUTH: API_SERVICE.USER + API_PERMISSION.PUBLIC + '/validate' + , //get 获取激验一次  post 二次
            POST_AUTH: API_SERVICE.USER + API_PERMISSION.PUBLIC + "/geetest/second",
};

let loadingCount = 0;

function showLoading() {
    if (loadingCount === 0) {
        api.showProgress({ title: '小蟹加载中...', text: '', modal: true });
    }
    loadingCount += 1;
}

function hideLoading() {
    if (loadingCount <= 0) {
        return;
    }
    loadingCount -= 1;
    if (loadingCount === 0) {
        api.hideProgress();
    }
}


function checkToLogin(ret) {
    // 30002 身份过期
    // 30005 未登陆
    if (ret.code === 30002) {
        logoutToClear();
        toastMiddle('身份已过期,请重新登录')
        setTimeout(() => {
            api.openWin({
                name: 'login_win',
                url: 'widget://html/login/login_win.html',
                slidBackEnabled: true,
                bounces: false,
                reload: true,
                pageParam: { key: 'value' }
            });
        }, 500)
        return false;
    }
}

function checkToken() {
    var token = $api.getStorage('accessToken')

    console.log(token)
    if (token) {
        return true;
    } else {
        // toastMiddle('您还没有登录')
        setTimeout(() => {
            api.openWin({
                name: 'login_win',
                url: 'widget://html/login/login_win.html',
                slidBackEnabled: true,
                bounces: false,
                reload: true,
                pageParam: { key: 'value' }
            });
        }, 500)
        return false;
    }
}

function checkHomeToken() {
    var token = api.getPrefs({
        sync: true,
        key: 'accessToken'
    });

    console.log(token)
    if (token) {
        return true;
    } else {
        // toastMiddle('您还没有登录')
        setTimeout(() => {
            api.openWin({
                name: 'login_win',
                url: 'widget://html/login/login_win.html',
                slidBackEnabled: true,
                bounces: false,
                reload: true,
                pageParam: { key: 'value' }
            });
        }, 500)
        return false;
    }
}

function checkUserInfoChange(ret) {
    if (ret.code === USER_INFO_CHANGE) {
        alert(ret.data.token);
        $api.setStorage('accessToken', ret.data.token);
        api.setPrefs({
            key: 'accessToken',
            value: ret.data.token
        });
        api.sendEvent({
            name: 'refreshUserInfo'
        });
    }
}

function logoutToClear() {
    $api.rmStorage('accessToken');
}

/**
 * get请求
 * @param apiUrl url地址
 * @param params 参数，json格式，会自动修改为query形式
 * @param loading 是否显示loading
 * @param callback 回调
 */
function fnGet(apiUrl, params, loading, callback) {
    if (params) {
        params = Object.keys(params).map(function (key) {
            if (params[key] !== "" && params[key] != null) {
                return key + "=" + params[key];
            }
        }).join("&");
    }
    params = params ? '?' + params : params;
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    if (loading) {
        // showLoading();
    }
    console.log('get请求地址: ' + host + apiUrl + params)
    console.log('get请求头:token ' + accessToken)
    api.ajax({
        url: host + apiUrl + params,
        method: 'get',
        timeout: 30,
        cache: true,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "app-Version": api.version
        }
    }, function (ret, err) {
        if (loading) {
            hideLoading();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * delete请求
 * @param {'url地址'} apiUrl
 * @param {'参数'} data
 * @param {'是否显示loading'} loading
 * @param callback 回调
 */
function fnDelete(apiUrl, data, loading, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    if (loading) {
        // showLoading();
    }
    api.ajax({
        url: host + apiUrl,
        method: 'delete',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "app-Version": api.version

        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        if (loading) {
            hideLoading();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * put请求，修改操作
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnPut(apiUrl, data, loading, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');

    if (loading) {
        // showLoading();
    }
    console.log("请求地址：" + apiUrl)
    console.log("请求参数：" + JSON.stringify(data))
    api.ajax({
        url: host + apiUrl,
        method: 'put',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "Content-Type": APPLICATION_JSON_UTF8_VALUE,
            "app-Version": api.version

        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        if (loading) {
            hideLoading();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * post请求
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnPost(apiUrl, data, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    // showLoading();
    console.log("请求地址：" + apiUrl)
    console.log("请求参数：" + JSON.stringify(data))
    api.ajax({
        url: host + apiUrl,
        method: 'post',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "Content-Type": APPLICATION_JSON_UTF8_VALUE,
            "app-Version": api.version

        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        hideLoading();
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * post请求
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnPostLoading(apiUrl, data, loading, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    if (loading) {
        showLoading();
    }
    console.log("请求地址：" + apiUrl)
    console.log("请求参数：" + JSON.stringify(data))
    api.ajax({
        url: host + apiUrl,
        method: 'post',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "Content-Type": APPLICATION_JSON_UTF8_VALUE,
            "app-Version": api.version

        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        if (loading) {
            hideLoading();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * post请求
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnPostUpData(apiUrl, data, loading, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    console.log("请求地址：" + apiUrl)
    console.log("请求参数：" + JSON.stringify(data))
    if (loading) {
        api.showProgress({
            title: '小蟹上传中...',
            text: '',
            modal: true
        });
    }
    api.ajax({
        url: host + apiUrl,
        method: 'post',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "Content-Type": APPLICATION_JSON_UTF8_VALUE,
            "app-Version": api.version

        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        if (loading) {
            api.hideProgress();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * post请求，添加操作
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnBodyPost(apiUrl, data, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    // showLoading();
    api.ajax({
        url: host + apiUrl,
        method: 'post',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "Content-Type": APPLICATION_JSON_UTF8_VALUE,
            "app-Version": api.version
        },
        data: {
            body: JSON.stringify(data)
        }
    }, function (ret, err) {
        hideLoading();
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}

/**
 * post请求，添加操作
 * @param apiUrl 请求地址
 * @param data 请求数据，json对象
 * @param callback 回调函数
 */
function fnBodyPostFile(apiUrl, data, values, loading, callback) {
    let signature = getSignature();
    let accessToken = $api.getStorage('accessToken');
    if (loading) {
        api.showProgress({
            title: '小蟹上传中...',
            text: '',
            modal: true
        });
    }
    api.ajax({
        url: host + apiUrl,
        method: 'post',
        timeout: 30,
        headers: {
            'App-Id': signature.appId,
            'Time-Stamp': signature.timeStamp,
            'Nonce-Str': signature.nonceStr,
            'Sign': signature.sign,
            'App-Channel': signature.appChannel,
            'access-token': accessToken,
            "app-Version": api.version
        },
        data: {
            values: values,
            files: data
        }
    }, function (ret, err) {
        if (loading) {
            api.hideProgress();
        }
        if (ret) {
            checkToLogin(ret);
            callback(ret, err);
        } else {
            callback(ret, err);
            // api.toast({ msg: '服务器连接失败' });
        }
    });
}



/**
 * 获取接口签名
 * @returns {{nonceStr: string, timeStamp: number, sign: (string|*)}}
 */
function getSignature() {
    const nonceStr = uuidv4();
    const timeStamp = new Date().getTime();
    const key = "App-Channel=" + appChannel + "&" +
        "App-Id=" + appId + "&" +
        "Nonce-Str=" + nonceStr + "&" +
        "Secret=" + appSecret + "&" +
        "Time-Stamp=" + timeStamp;
    const sign = hex_md5(key);
    return { appId: appId, timeStamp: timeStamp, nonceStr: nonceStr, sign: sign, appChannel: appChannel };
}

function uuidv4() {
    return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
        (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
    );
}

/**
 * 获取随机字符串
 * @returns {string}
 */
function guid() {
    function s4() {
        return Math.floor((1 + Math.random()) * 0x10000)
            .toString(16)
            .substring(1);
    }

    return (
        s4() +
        s4() +
        "-" +
        s4() +
        "-" +
        s4() +
        "-" +
        s4() +
        "-" +
        s4() +
        s4() +
        s4()
    );
}

var hexcase = 0;
var chrsz = 8;

/**
 * md5 加密
 * @param s 需要加密的串
 */
function hex_md5(s) {
    return binl2hex(core_md5(str2binl(s), s.length * chrsz));
}

function core_md5(x, len) {
    x[len >> 5] |= 0x80 << (len % 32);
    x[(((len + 64) >>> 9) << 4) + 14] = len;
    var a = 1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d = 271733878;
    for (var i = 0; i < x.length; i += 16) {
        var olda = a;
        var oldb = b;
        var oldc = c;
        var oldd = d;

        a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
        d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
        c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
        b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
        a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
        d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
        c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
        b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
        a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
        d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
        c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
        b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
        a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
        d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
        c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
        b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
        a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
        d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
        c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
        b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
        a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
        d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
        c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
        b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
        a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
        d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
        c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
        b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
        a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
        d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
        c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
        b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
        a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
        d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
        c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
        b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
        a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
        d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
        c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
        b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
        a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
        d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
        c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
        b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
        a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
        d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
        c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
        b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
        a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
        d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
        c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
        b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
        a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
        d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
        c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
        b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
        a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
        d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
        c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
        b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
        a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
        d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
        c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
        b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);

        a = safe_add(a, olda);
        b = safe_add(b, oldb);
        c = safe_add(c, oldc);
        d = safe_add(d, oldd);
    }
    return Array(a, b, c, d);
}

function md5_cmn(q, a, b, x, s, t) {
    return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}

function md5_ff(a, b, c, d, x, s, t) {
    return md5_cmn((b & c) | (~b & d), a, b, x, s, t);
}

function md5_gg(a, b, c, d, x, s, t) {
    return md5_cmn((b & d) | (c & ~d), a, b, x, s, t);
}

function md5_hh(a, b, c, d, x, s, t) {
    return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}

function md5_ii(a, b, c, d, x, s, t) {
    return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
}

function safe_add(x, y) {
    var lsw = (x & 0xffff) + (y & 0xffff);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 0xffff);
}

function bit_rol(num, cnt) {
    return (num << cnt) | (num >>> (32 - cnt));
}

function str2binl(str) {
    var bin = Array();
    var mask = (1 << chrsz) - 1;
    for (var i = 0; i < str.length * chrsz; i += chrsz)
        bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
    return bin;
}

function binl2hex(binarray) {
    var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
    var str = "";
    for (var i = 0; i < binarray.length * 4; i++) {
        str +=
            hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xf) +
            hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xf);
    }
    return str;
}

function vialeParam(param) {
    var newParam = "";
    var params = param.split("&");
    for (var i = 0; i < params.length; i++) {
        if (params[i].split("=").length > 0) {
            if (params[i].split("=")[1] != "" && params[i].split("=")[1] != null) {
                if (i != 0) {
                    newParam += "&";
                }
                newParam += params[i];
            }
        }
    }
    return newParam;
}
